﻿''' <summary>
''' 表示实现信息发送器的基类，所有的信息发送器都应继承此类而不是直接实现IInfoSender接口
''' </summary>
''' <remarks></remarks>
Public MustInherit Class InfoSenderBase
    Inherits PropertyChangeBase
    Implements IInfoSender
    ''' <summary>
    ''' 获取部件是否可以工作的信息
    ''' </summary>
    ''' <returns>可否工作状态</returns>
    ''' <remarks></remarks>
    Public MustOverride Function GetAvailability() As Boolean Implements IInfoSender.GetAvailability
    ''' <summary>
    ''' 当发送器出现错误时引发的事件
    ''' </summary>
    ''' <remarks></remarks>
    Public Event SenderError(ByVal sender As Object, ByVal e As SenderErrorEventArgs) Implements IInfoSender.SenderError
    ''' <summary>
    ''' 发送特定消息
    ''' </summary>
    ''' <param name="message">要发送的信息</param>
    ''' <remarks></remarks>
    Public MustOverride Sub SendInfo(ByVal message As String) Implements IInfoSender.SendInfo
    ''' <summary>
    ''' 在对部件进行设置时调用
    ''' </summary>
    ''' <remarks></remarks>
    Public MustOverride Sub ShowSetting() Implements IInfoSender.ShowSetting
    ''' <summary>
    ''' 在程序结束时调用，指示部件结束工作
    ''' </summary>
    ''' <remarks></remarks>
    Public MustOverride Sub ShutDown() Implements IInfoSender.ShutDown
    ''' <summary>
    ''' 在程序开始时调用，指示部件开始工作
    ''' </summary>
    ''' <remarks></remarks>
    Public MustOverride Sub StartUp() Implements IInfoSender.StartUp

    Protected Sub OnError(ByVal exception As Exception, ByRef isHandled As Boolean)
        RaiseEvent SenderError(Me, New SenderErrorEventArgs(exception, isHandled))
    End Sub

    Private _IsUsing As Boolean
    Public Property IsUsing As Boolean Implements IInfoSender.IsUsing
        Get
            Return _IsUsing
        End Get
        Set(ByVal value As Boolean)
            If _IsUsing <> value Then
                OnPropertyChanging("IsUsing")
                _IsUsing = value
                OnPropertyChanged("IsUsing")
            End If
        End Set
    End Property
End Class
